package com.company.controller;

import com.company.common.R;
import com.company.entity.SysUser;
import com.company.service.SysUserService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class SysController {
    @Resource
    SysUserService sysUserService;

    @CrossOrigin(origins = "*")
    @RequestMapping("/selectAllPage/{page}")
    public R selectAllPage(@PathVariable("page") int page){
        //第一个参数表示第几页，第二个参数表示每页的条数
        PageHelper.startPage(page,2);
        List<SysUser> list = this.sysUserService.list();
        PageInfo<Object> pageInfo = new PageInfo<>(list);
        return new R().add("pageInfo",pageInfo);
    }

    @CrossOrigin(origins = "*")
    @RequestMapping("/selectAllsys")
    public R selectAllsys(){
        List<SysUser> list = this.sysUserService.list();
        return new R().add("list",list);
    }
}
